<?php


namespace app\home\controller;


use app\common\controller\BaseController;
use app\home\model\TaskRecord as recordModel;
use think\App;
use think\db\Where;

class TaskRecord extends BaseController
{
    protected $model;

    public function __construct(App $app, recordModel $record)
    {
        parent::__construct($app);
        $this->model = $record;
    }

    /**
     * @return mixed
     * 任务订单列表
     */
    public function query()
    {
        $where = [];
        $where['receiver_id'] = $this->params['member_id'];
        $taskStatus = input('task_status', -1);
        $taskStatus == -1 || $where['task_status'] = $taskStatus;
        $field = "id,id expiredTime,task_id task,receiver_id receiver_name
       ,task_id task_integral,finish_step,task_status,is_expired,create_time,post_time,finish_time";
        $page = input('page/d', 1);
        $pageSize = input('page_size/d', 10);
        $order = ['create_time' => 'DESC'];
        return $this->model->getList($where, $field, $order, $page, $pageSize);
    }

    /**
     * @return array
     * 过期时间
     */
    public function expire()
    {
        try {
            return $this->model->expireTime($this->params);
        } catch (\Exception $ex) {
            return $this->returnException($ex);
        }
    }
}